package com.example.myowntodo.fragement_test
import android.R
import android.support.test.rule.ActivityTestRule
import androidx.core.os.bundleOf
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.myowntodo.fet_probe.presentation.fragment.FetLoginFragment
//import androidx.test.rule.ActivityTestRule
import com.example.myowntodo.fet_todo.presentation.MainActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith


// TODO: 不能单独启动Fragment来测试Fragment的ui布局？
@RunWith(AndroidJUnit4::class)
class FragmentLoginTest {
//    @Rule
//    var activityRule: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)

//    @Test
//    fun clickButtonTest() {
//        // 1.匹配View
//        Espresso.onView(withId(R.id.my_button)) // 使用资源ID匹配View
//            // 2.执行View行为
//            .perform(ViewActions.click()) // 执行点击行为
//            // 3.验证View
//            .check(ViewAssertions.matches(withId(R.id.my_button))) // 验证按钮是否被点击
//    }

    @Test fun testEventFragment() {
        // The "fragmentArgs" argument is optional.
//        val fragmentArgs = bundleOf("selectedListItem" to 0)
//        val scenario = launchFragmentInContainer<FetLoginFragment>(fragmentArgs)
        val scenario = launchFragmentInContainer<FetLoginFragment>(themeResId = R.style.Theme_NoTitleBar)
        // 使用Espresso进行UI测试
//        onView(withId(R.id.some_view_id)).check(matches(isDisplayed()))
    }
}

